import React from 'react';
import './Radio.scss';
import classNames from 'classnames';


interface RadioProps {
  optionsList: { label: string, value: number }[];
  value: number;
  onChange: (value: number) => void;
}

const Radio: React.FunctionComponent<RadioProps> = ({ optionsList, value, onChange }) => {

  const changeActive = (value: number) => {
    onChange(value);
  };

  return (
    <div className="radio">
      {
        optionsList.map((item, index) => <a className={classNames('item', item.value === value ? 'active' : '')} key={index} onClick={() => changeActive(item.value)}>{item.label}</a>)
      }
    </div>
  );
};

export default Radio;